import { Color } from "cc";
import { EventId } from "../../../new/event/EventId";
import EventMgr from "../../../new/event/EventMgr";
import { TreateResult } from "../../../new/trigger/const/ITriggerResult";
import { BattleRoleUI } from "../../roleUI/BattleRoleUI";
import { ActionBase } from "./ActionBase";

/**
 * 治疗行动
 */
export class TreateAction extends ActionBase {
    targetUI: BattleRoleUI;
    result: TreateResult
    constructor(targetUI: BattleRoleUI, result: TreateResult) {
        super()
        this.targetUI = targetUI;
        this.result = result;
    }

    excute(): void {
        let damage = this.result.treateNum;
        this.targetUI.onBleed();
        this.targetUI.updateHp(damage);
        //飘字
        EventMgr.ins.event(EventId.FLOAT_TXT, { targetUI: this.targetUI, txt: `治疗:${this.result.treateNum}`, color: Color.GREEN });
    }
}